<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box"></div>
    <button id="btn">longmao</button>
    <button class="eldEle">克隆</button>
    <script>
      //先找到button，绑定事件，添加图片 在父元素box上添加
      var boxEle = document.getElementById('box');
      var imgNode;
      document.getElementById('btn').onclick = function () {
        imgNode = document.createElement('img');
        imgNode.src = '../img/mini2.jpg';
        boxEle.appendChild(imgNode);
      };
      document.getElementsByClassName('eldEle')[0].onclick = function () {
        var img = imgNode.cloneNode(true);
        boxEle.appendChild(img);
      };
    </script>
  </body>
</html>
